﻿<%@ Page Title="toolsRecord" Language="C#" MasterPageFile="~/EasyUI.master" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="jnxc.Web.toolsRecord.List" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="../Script/sitedata.js"></script>
    <script src="../Script/combobox.js"></script>
    <script src="../Script/city.js"></script>
   <%-- <script src="../Script/main.js"></script>--%>
    <script type="text/javascript">
        $(function () {
            InitGird();
            InitSearch();
        });
        //初始化表格
        function InitGird() {
            $('#tt').datagrid({
                title: '诱虫灯（引诱剂、粘虫色板）调查记录表', //表格标题
                url: 'GetTools.ashx', //请求数据的页面
                sortName: 'xbhbh', //排序字段
                //idField: 'routinId', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                singleSelect: true,
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                method: 'post',
                columns: [[
                    {
                        title: '省', field: 'pname', width: 100, formatter: function (value, row) {
                            return row.pname + '(' + row.pbh + ')';
                        }
                    },
                    {
                        title: '市', field: 'cname', width: 100, formatter: function (value, row) {
                            return row.cname + '(' + row.cbh + ')';
                        }
                    },
                    {
                        title: '县', field: 'coname', width: 100, formatter: function (value, row) {
                            return row.coname + '(' + row.cobh + ')';
                        }
                    },
                    {
                        title: '乡镇', field: 'tname', width: 100, formatter: function (value, row) {
                            return row.tname + '(' + row.tbh + ')';
                        }
                    },
                    { title: '小班号', width: 100, field: 'xbhbh' },
                    //{ title: '踏查点', field: 'tcdname' },
                    {
                        title: '详细', field: '', width: 150,
                        formatter: function (value, row, index)
                        { return '<a href="#" onclick="top.addTab(\'诱虫灯' + row.tname + row.xbhbh + '\',\'/toolsRecord/listr.aspx?tn=' + row.tname + '&tbh=' + row.tbh + '&xbhbh=' + row.xbhid + '\', \'icon icon-magic\');">详细</a>'; }
                    }
                ]],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "dis" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true //行号
            });


        }
        //初始化搜索框
        function InitSearch() {
            loadNameEdit();
            $.ajax({
                type: "post",
                dataType: "json",
                url: "../admin/getinfo.ashx?action=level",
                success: function aa(data) {
                    $('#level').val(data[0].level);
                    if (data[0].level == 3) {
                        provinceName = data[0].province;
                        $('#uprovince').combobox('setValue', data[0].province);
                        $("#dprovince").hide();
                    }
                    if (data[0].level == 2) {
                        provinceName = data[0].province;
                        $('#uprovince').combobox('setValue', data[0].province);
                        cityName = data[0].city;
                        $('#ucity').combobox('setValue', data[0].city);
                        $("#dprovince").hide();
                        $("#dcity").hide();
                    }
                    if (data[0].level == 1) {
                        provinceName = data[0].province;
                        $('#uprovince').combobox('setValue', data[0].province);
                        cityName = data[0].city;
                        $('#ucity').combobox('setValue', data[0].city);
                        areaName = data[0].county;
                        $('#ucounty').combobox('setValue', data[0].county);
                        $("#dprovince").hide();
                        $("#dcity").hide();
                        $("#dcounty").hide();
                    }
                }
            });
        }
        function getQueryParams(queryParams) {
            var uprovince = $("#uprovince").combobox("getValue");
            var ucity = $("#ucity").combobox("getValue");
            var ucounty = $("#ucounty").combobox("getValue");
            var StartTime = $("#StartTime").datebox("getValue");
            var EndTime = $("#EndTime").datebox("getValue");
            queryParams.uprovince = uprovince;
            queryParams.ucity = ucity;
            queryParams.ucounty = ucounty;
            queryParams.StartTime = StartTime;
            queryParams.EndTime = EndTime;
            return queryParams;
        }
        //增加查询参数，重新加载表格  
        function reloadgrid() {
            //查询参数直接添加在queryParams中      
            var queryParams = $('#tt').datagrid('options').queryParams;
            getQueryParams(queryParams);
            $('#tt').datagrid('options').queryParams = queryParams;
            $("#tt").datagrid('reload');
        }

    </script>
    <style>
        .fitem {
            float: left;
        }

            .fitem label {
                width: 30px;
                line-height: 24px;
            }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table id="tt">
    </table>
    <div id="tab_toolbar" style="padding: 4px;">
        <table cellpadding="0" cellspacing="0" style="width: 100%">
            <tr>

                <td style="padding-left: 2px">

                    <div style="padding: 2px;">

                        <div class="fitem" id="dprovince">
                            <label>省：</label>
                            <input id="uprovince" name="uprovince" class="easyui-combobox" data-options="width:'100'" />
                        </div>
                        <div class="fitem" id="dcity">
                            <label>市：</label>
                            <input id="ucity" name="ucity" class="easyui-combobox" data-options="width:'100'" />
                        </div>
                        <div class="fitem" id="dcounty">
                            <label>县：</label>
                            <input id="ucounty" name="ucounty" class="easyui-combobox" data-options="width:'100'" />
                        </div>
                        <div class="fitem" style="width:300px;"> 
                            时间从:  
           <input id="StartTime" class ="easyui-datebox" style="width: 100px" />  
           到:  
           <input id="EndTime" class="easyui-datebox" style="width: 100px" />  
                        </div>
                          
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="reloadgrid()">查找</a>
                    </div>
                </td>
            </tr>
        </table>
    </div>   
</asp:Content>

